#ifndef ACCEPTOR_H
#define ACCEPTOR_H

#include <functional>
#include <memory>
#include <string>

class AcceptorTestHelper;
class EventLoop;
class Channel;
class Socket;

class Acceptor {
public:
     friend class AcceptorTestHelper;
    using NewConnectionCallback = std::function<void(int sockfd, const std::string& peerAddr)>;

    Acceptor(EventLoop* loop, const std::string& ip, uint16_t port);
    ~Acceptor();

    virtual void listen();
    void setNewConnectionCallback(NewConnectionCallback cb);

private:
    void handleRead();

    EventLoop* loop_;
    std::unique_ptr<Socket> listenSocket_;
    std::unique_ptr<Channel> listenChannel_;
    NewConnectionCallback newConnCallback_;
};
#endif